package la.iok.hzsvn.lewin.movie.operation.service;

import la.iok.hzsvn.lewin.movie.operation.entity.FeeRecord;
import la.iok.hzsvn.lewin.movie.operation.mapper.FeeRecordMapper;
import la.iok.hzsvn.lewin.mybatis.service.BaseServiceImpl;
import la.iok.hzsvn.share.annotations.Nullable;
import org.springframework.stereotype.Service;

@Service
public class FeeRecordServiceImpl extends BaseServiceImpl<FeeRecord, FeeRecordMapper,Long> implements FeeRecordService {
    public FeeRecordServiceImpl(FeeRecordMapper mapper) {
        super(mapper);
    }

    @Override
    public Long save(@Nullable Long luckyMoneyId, @Nullable Long playRecordId, int amount) {
        if(luckyMoneyId == null || playRecordId == null || amount <= 0){
            return null;
        }
        FeeRecord record = new FeeRecord();
        record.setPlayRecordId(playRecordId);
        record.setAmount(amount);
        record.setLuckyMoneyId(luckyMoneyId);
        insertSelective(record);
        return record.getId();
    }
}
